package BookManage.Operation;

import BookManage.Book;
import BookManage.BookDao;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 强仔
 * Date: 2022-01-19
 * Time: 10:38
 */
public class AddOperation implements IOperation {

    @Override
    public void work() {
        BookDao bookDao = new BookDao();
        Book book = new Book();
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入书的名字:");
        book.setName(scanner.next());
        System.out.println("请输入书的作者:");
        book.setAuthor(scanner.next());
        System.out.println("请输入书的类型:");
        book.setType(scanner.next());
        System.out.println("请输入书的价格");
        book.setPrice(scanner.nextInt());
        //无需设置bookId和isBorrowed（），在BookDao的addBook中已经"写死“
        bookDao.addBook(book);
    }
}
